package com.zf.apartment.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.ArrayList;
import java.util.List;

import com.zf.apartment.domain.Property;
import com.zf.apartment.mapper.PropertyMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zf.apartment.mapper.PropertyDataMapper;
import com.zf.apartment.domain.PropertyData;
import com.zf.apartment.service.IPropertyDataService;

/**
 * 属性数据Service业务层处理
 *
 * @author rxf
 * @date 2024-10-08
 */
@Service
public class PropertyDataServiceImpl extends ServiceImpl<PropertyDataMapper, PropertyData> implements IPropertyDataService {
    @Autowired
    private PropertyDataMapper propertyDataMapper;
    @Autowired
    private PropertyMapper propertyMapper;

    /**
     * 查询属性数据
     *
     * @param propertyDataId 属性数据主键
     * @return 属性数据
     */
    @Override
    public PropertyData selectPropertyDataByPropertyDataId(Long propertyDataId) {
        return propertyDataMapper.selectPropertyDataByPropertyDataId(propertyDataId);
    }

    /**
     * 查询属性数据列表
     *
     * @param propertyData 属性数据
     * @return 属性数据
     */
    @Override
    public List<PropertyData> selectPropertyDataList(PropertyData propertyData) {
        return propertyDataMapper.selectPropertyDataList(propertyData);
    }

    /**
     * 新增属性数据
     *
     * @param propertyData 属性数据
     * @return 结果
     */
    @Override
    public int insertPropertyData(PropertyData propertyData) {
            return propertyDataMapper.insertPropertyData(propertyData);
    }

    /**
     * 修改属性数据
     *
     * @param propertyData 属性数据
     * @return 结果
     */
    @Override
    public int updatePropertyData(PropertyData propertyData) {
        return propertyDataMapper.updatePropertyData(propertyData);
    }

    /**
     * 批量删除属性数据
     *
     * @param propertyDataIds 需要删除的属性数据主键
     * @return 结果
     */
    @Override
    public int deletePropertyDataByPropertyDataIds(Long[] propertyDataIds) {
        return propertyDataMapper.deletePropertyDataByPropertyDataIds(propertyDataIds);
    }

    /**
     * 删除属性数据信息
     *
     * @param propertyDataId 属性数据主键
     * @return 结果
     */
    @Override
    public int deletePropertyDataByPropertyDataId(Long propertyDataId) {
        return propertyDataMapper.deletePropertyDataByPropertyDataId(propertyDataId);
    }

    @Override
    public List<PropertyData> selectPropertyDataListByPropertyId(Long propertyId) {
        Property property = propertyMapper.selectPropertyByPropertyId(propertyId);
        List<PropertyData> propertyDataList=new ArrayList<>();
        if(property.getPropertyType()!=null){
            propertyDataList =propertyDataMapper.selectPropertyDataByPropertyDataType(property.getPropertyType());
        }
        return propertyDataList;
    }

    @Override
    public List<PropertyData> findPropertyDataList(PropertyData propertyData) {
        return propertyDataMapper.findPropertyDataList(propertyData);
    }
}